package com.hb.B_面向对象.F_模式匹配

import sun.security.provider.SHA

/**
 * 参考 E_密封类_代数类型 中的Shape
 */
fun main() {

}

sealed class Shape{
    class Circle(val redius:Double):Shape()
    class Rectangle(val width:Double,val height:Double):Shape()
    class Triangle(val base:Double,val height:Double):Shape()
}

fun getArea(shape: Shape):String =when(shape) {
    is Shape.Circle -> "计算圆面积"
    is Shape.Rectangle -> "计算长方形面积"
    is Shape.Triangle -> "计算三角形面积"
}